package com.ddxz.spark.read.struct

import java.text.SimpleDateFormat
import java.util.Date

import com.ddxz.spark.read.constant.CommonConstData._

object MySqlEntity {

  case class FacilityEntity(ips: String, domain: String, facilityId: String, deptId: String) {
    override def toString: String = Array(facilityId, deptId).mkString(hiveSplit)
  }


  case class BotortrojanEntity(sourceType: String, source: String, detailTypeCode: String, basicType: String,
                               subType: String, detailType: String, extType: String, timeAll: String, hour: String,
                               sIp: String, sIpN: String, sPort: String, dIp: String, dIpN: String, dPort: String,
                               controlRelation: String, dataReturn: String, sIpBelong: String, sIpArea: String,
                               sIpOperator: String, dIpBelong: String, dIpArea: String, dIpOperator: String,
                               sIpLng: String, sIpLat: String, dIpLng: String, dIpLat: String, mPositionType: String,
                               mArea: String, mOperator: String, mPGp: String, mStringernet: String, mMark: String) {
    override def toString: String = Array(sourceType, source, detailTypeCode, basicType, subType, detailType, extType,
      timeAll, getYMD(timeAll), hour, sIp, sIpN, sPort, dIp, dIpN, dPort, controlRelation, dataReturn, sIpBelong, sIpArea,
      sIpOperator, dIpBelong, dIpArea, dIpOperator, sIpLng, sIpLat, dIpLng, dIpLat, mPositionType, mArea, mOperator, mPGp,
      mStringernet, mMark).mkString(hiveSplit)
  }

  def getYMD(timeall: String): String = {
    val newtime: Date = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(timeall)
    val ymd = new SimpleDateFormat("yyyyMMdd").format(newtime)
    ymd
  }
}
